import service from '.'

const userApi = {
    login(username, password, captcha, uuid) {
        return service.post('/login', { username, password, captcha, uuid }, {
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            }
        })
    },
    getInfo(currentPage, role, name) {
        return service.get('/admin/user', { params: { currentPage, role, name } });
    },
    getById(id) {
        return service.get(`/admin/user/${id}`);
    },
    addInfo(user) {
        return service.post('/admin/user', user);
    },
    delInfo(id) {
        return service.delete(`/admin/user/${id}`);
    },
    updateInfo(user) {
        return service.put('/admin/user', user);
    },
    addInfoU(user) {
        return service.post('/addUser', user);
    },
    getEmpList(did) {
        return service.get('/admin/user/list',{params:{did}});
    },
    getUserList() {
        return service.get('/admin/user/userList');
    },
    upPassword(id, oldPassword, password, rpassword) {
        return service.post('/admin/user/password', { id, oldPassword, password, rpassword }, {
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            }
        });
    },
    getCaptcha() {
        return service.get('/captcha');
    },
    updateAdmin(oldId, userId) {
        return service.put('/admin/department/updateAdmin',{oldId, userId}, {
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            }
        })
    },
    register(realName, username, password) {
        return service.post('/addUser',{realName, username, password})
    }
}

export default userApi;